// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import CM from "../../../lib/cache/CM";
import { selfCls } from "../../../lib/common/Decorator";
import DField from "../../cache/DField";
import MachineManager from "../manager/MachineManager";
import GOPlay from "./GOPlay";

const {ccclass, property} = cc._decorator;

@selfCls
export default class GPPassMission extends GOPlay {

    onRunning(): void {
        this.createMachineByFieldData();//创建地图

        CM.ins(CM).get(DField).setMapData(0, 5, 10);
    }

    //根据地图数据载入machine
    createMachineByFieldData() {
        let maxCol = CM.ins(CM).get(DField).col
        let data = CM.ins(CM).get(DField).content

        for (let i = 0; i < data.length; i++) {
            let col = i%maxCol;
            let row = Math.floor(i/maxCol);
            let machineId = data[i];
            MachineManager.ins(MachineManager).createMachine({row:row, col:col, id:machineId})
        }
    }

    //创建角色
    createRole() {

    }

    //过关判断条件
    isPass():boolean {
        return false;
    }

    onUpdate(dt: any): void {
        
    }

    onStop(): void {
        
    }
}
